package org.come.mouslisten;

import java.math.BigDecimal;
import java.util.Map;

import org.come.Frame.TeamJframe;
import org.come.Frame.TestPetJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.TestPetJpanel;
import org.come.Jpanel.TestpackJapnel;
import org.come.Jpanel.WorldMapJpanel;
import org.come.bean.ConfigureBean;
import org.come.entity.Mount;
import org.come.entity.RoleSummoning;
import org.come.model.Configure;
import org.come.model.InternalForm;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.*;

import com.tool.image.ImageMixDeal;
import com.tool.pet.PetProperty;
import com.tool.role.RoleData;
import org.skill.frame.SkillMainFrame;

public class ChangeMouseSymbolMouslisten {

    public static void dianji(String FlagMes) {
        switch (FlagMes) {
            case "切磋":
                MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE6);
                Music.addyinxiao("开关窗口.mp3");
                break;
            case "组队":
                if (ZhuFrame.getZhuJpanel().getTeamState() == 1) {
                    ZhuFrame.getZhuJpanel().setTeamState(0);
                    String sendmes = Agreement.getAgreement().team6Agreement("");
                    SendMessageUntil.toServer(sendmes);
                } else {
                    ZhuFrame.getZhuJpanel().showIsTeamBtn(true, 1);
//            其他菜单关闭
                    ZhuFrame.getZhuJpanel().tradingMenu(false, 0);
                    ZhuFrame.getZhuJpanel().settingsMenu(false, 0);
                    ZhuFrame.getZhuJpanel().showflybtn(false, 0);
                }
                break;
            case "坐骑":
                ZhuFrame.getZhuJpanel().showflybtn(true, 1);
//            其他菜单关闭
                ZhuFrame.getZhuJpanel().tradingMenu(false, 0);
                ZhuFrame.getZhuJpanel().settingsMenu(false, 0);
                ZhuFrame.getZhuJpanel().showIsTeamBtn(false, 0);
                break;
            case "设置":
                ZhuFrame.getZhuJpanel().settingsMenu(true, 1);
//            其他菜单关闭
                ZhuFrame.getZhuJpanel().tradingMenu(false, 0);
                ZhuFrame.getZhuJpanel().showflybtn(false, 0);
                ZhuFrame.getZhuJpanel().showIsTeamBtn(false, 0);

                break;
            case "交易菜单":
                ZhuFrame.getZhuJpanel().tradingMenu(true, 1);
//            其他菜单关闭
                ZhuFrame.getZhuJpanel().settingsMenu(false, 0);
                ZhuFrame.getZhuJpanel().showflybtn(false, 0);
                ZhuFrame.getZhuJpanel().showIsTeamBtn(false, 0);

                break;
            case "技能":

                SkillMainFrame.getSkillMainFrame().getSkillMainPanel().changeBtnPanel(0);
                FormsManagement.showForm(82);
                Music.addyinxiao("开关窗口.mp3");

                break;
            case "组队快捷键":
                if (ZhuFrame.getZhuJpanel().getTeamState() == 1) {
                    ZhuFrame.getZhuJpanel().setTeamState(0);
                    String sendmes = Agreement.getAgreement().team6Agreement("");
                    SendMessageUntil.toServer(sendmes);
                } else {
                    if (ImageMixDeal.userimg.getRoleShow().getTroop_id() != null) {
                        InternalForm internalForm = FormsManagement.getInternalForm2(13);
                        if (internalForm != null && internalForm.getFrame().isVisible()) {
                            FormsManagement.HideForm(13);
                        } else {
                            TeamJframe.getTeamJframe().getTeamjpanel().show(ImageMixDeal.userimg.getRoleShow(), RoleData.getRoleData().getTeamBean());
                        }
                    } else {
                        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE2);
                    }
                }
                break;
            case "交易":
                MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE5);
                break;
            case "给予":
                MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE3);
                break;
            case "整理":
                TestpackJapnel.showIsTeamBtnS(true, 1);
                break;
            case "海底迷宫":
                WorldMapJpanel.showIsTeamBtnSx(true, 1);
//            其他菜单关闭
                WorldMapJpanel.showduyu(false, 0);
                WorldMapJpanel.showdayanta(false, 0);
                WorldMapJpanel.showfengcao(false, 0);
                WorldMapJpanel.showlongku(false, 0);
                break;
            case "地狱迷宫":
                WorldMapJpanel.showduyu(true, 1);
//            其他菜单关闭
                WorldMapJpanel.showIsTeamBtnSx(false, 0);
                WorldMapJpanel.showdayanta(false, 0);
                WorldMapJpanel.showfengcao(false, 0);
                WorldMapJpanel.showlongku(false, 0);
                break;
            case "大雁塔":
                WorldMapJpanel.showdayanta(true, 1);
//            其他菜单关闭
                WorldMapJpanel.showIsTeamBtnSx(false, 0);
                WorldMapJpanel.showduyu(false, 0);
                WorldMapJpanel.showfengcao(false, 0);
                WorldMapJpanel.showlongku(false, 0);
                break;
            case "凤巢":
                WorldMapJpanel.showfengcao(true, 1);
//            其他菜单关闭
                WorldMapJpanel.showIsTeamBtnSx(false, 0);
                WorldMapJpanel.showduyu(false, 0);
                WorldMapJpanel.showdayanta(false, 0);
                WorldMapJpanel.showlongku(false, 0);
                break;
            case "龙窟":
                WorldMapJpanel.showlongku(true, 1);
//            其他菜单关闭
                WorldMapJpanel.showIsTeamBtnSx(false, 0);
                WorldMapJpanel.showduyu(false, 0);
                WorldMapJpanel.showdayanta(false, 0);
                WorldMapJpanel.showfengcao(false, 0);
                break;
        }
//        else if(FlagMes.equals("坐骑")) {
//            ZhuFrame.getZhuJpanel().showflybtn(true,1);
//        }
    }

    /** 坐骑管制召唤兽加技能属性 */
    public static void addProperties(RoleSummoning roleSummoning, Mount mount) {
        if (UserMessUntil.getChosePetMes() != null
                && UserMessUntil.getChosePetMes().getSid().compareTo(roleSummoning.getSid()) == 0) {
            PetAddPointMouslisten.showPetValue();
            if (FormsManagement.getframe(58).isVisible()) {
                PetProperty.ShowQl(roleSummoning);
            }
        }
    }

    /** 坐骑去除管制召唤兽清除坐骑技能属性 */
    public static void clearPropertie(RoleSummoning roleSummoning) {
        if (UserMessUntil.getChosePetMes() != null
                && UserMessUntil.getChosePetMes().getSid().compareTo(roleSummoning.getSid()) == 0) {
            PetAddPointMouslisten.showPetValue();
            if (FormsManagement.getframe(58).isVisible()) {
                PetProperty.ShowQl(roleSummoning);
            }
        }
    }

    /** 放生召唤兽的方法 */
    public static void releasePet(RoleSummoning roleSummoning, boolean isHuaLian) {
        String sendmes = Agreement.getAgreement().PetReleaseAgreement(
                (isHuaLian?"1=":"0=")+GsonUtil.getGsonUtil().getgson().toJson(roleSummoning.getSid()));
        SendMessageUntil.toServer(sendmes);
        int exi = -1;
        for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
            if (UserMessUntil.getPetListTable().get(i).getSid().compareTo(roleSummoning.getSid()) == 0) {
                exi = i;
            }
        }
        UserMessUntil.getPetListTable().remove(exi);

        TestPetJpanel.showListModel(UserMessUntil.getPetListTable(), RoleData.getRoleData().getLoginResult().getSummoning_id());

        FormsManagement.HideForm(19);
        // 判断是否还有召唤兽
        if (UserMessUntil.getPetListTable().size() <= 0) {// 没有
            TestPetJpanel.getLabname().setText("");
            TestPetJpanel.getLabHP().setText("");
            TestPetJpanel.getLabMP().setText("");
            TestPetJpanel.getLabAP().setText("");
            TestPetJpanel.getLabSP().setText("");
            TestPetJpanel.getLabEXP().setText("");
            TestPetJpanel.getLabpower().setText("");
            TestPetJpanel.getLabspeed().setText("");
            TestPetJpanel.getLabpointnumber().setText("");
            TestPetJpanel.getLabrootbone().setText("");
            TestPetJpanel.getLabintelligence().setText("");
            TestPetJpanel.getLablevel().setText("");
            TestPetJpanel.getLabloyalty().setText("");
            UserMessUntil.setChosePetMes(null);
        } else {
            // 判断是否有参战的召唤兽
            if (RoleData.getRoleData().getLoginResult().getSummoning_id() != null) {
                int exi2 = 0;
                for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
                    if (RoleData.getRoleData().getLoginResult().getSummoning_id()
                            .compareTo(UserMessUntil.getPetListTable().get(i).getSid()) == 0) {
                        exi2 = i;
                    }
                }
                // 展示参战的召唤兽信息
                UserMessUntil.setChosePetMes(UserMessUntil.getPetListTable().get(exi2));
                PetAddPointMouslisten.showPetValue();
            } else {
                // 展示第一只召唤兽的信息
                UserMessUntil.setChosePetMes(UserMessUntil.getPetListTable().get(0));
                PetAddPointMouslisten.showPetValue();
            }
        }
        // 关闭召唤兽技能面板
        FormsManagement.HideForm(18);
    }




    public static void refreshNedan(RoleSummoning roleSummoning) {
        ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        Configure configure = item.get(new BigDecimal(1));





        if (roleSummoning != null) {
            for (int i = 0; i < Integer.parseInt(configure.getNdslsx()); i++) {//召唤兽内丹
                TestPetJpanel.getLabNedan()[i].setGoodstable(null);
                TestPetJframe.getTestPetJframe().getTestPetJpanel().remove(TestPetJpanel.getLabNedan()[i]);
            }
            if (roleSummoning.getInnerGoods() != null && !"".equals(roleSummoning.getInnerGoods())) {
                String strings[] = roleSummoning.getInnerGoods().split("\\|");
                if (strings.length > 0) {
                    for (int i = 0; i < strings.length; i++) {
                        TestPetJframe.getTestPetJframe().getTestPetJpanel().add(TestPetJpanel.getLabNedan()[i]);
                        TestPetJpanel.getLabNedan()[i].setGoodstable(GoodsListFromServerUntil.fushis
                                .get(new BigDecimal(strings[i])));
                    }
                }
            } else {
                for (int i = 0; i < Integer.parseInt(configure.getNdslsx()); i++) {//召唤兽内丹
                    TestPetJpanel.getLabNedan()[i].setGoodstable(null);
                    TestPetJframe.getTestPetJframe().getTestPetJpanel().remove(TestPetJpanel.getLabNedan()[i]);
                }
            }
        }
    }
    public static void decomposePet(final RoleSummoning roleSummoning) {
        final String sendmes = Agreement.getAgreement().PetDecomposeAgreement(GsonUtil.getGsonUtil().getgson().toJson(roleSummoning.getSid()));
        SendMessageUntil.toServer(sendmes);
        int exi = -1;

        int exi2;
        for (exi2 = 0; exi2 < UserMessUntil.getPetListTable().size(); ++exi2) {
            if (UserMessUntil.getPetListTable().get(exi2).getSid().compareTo(roleSummoning.getSid()) == 0) {
                exi = exi2;
            }
        }

        UserMessUntil.getPetListTable().remove(exi);
        TestPetJpanel.showListModel(UserMessUntil.getPetListTable(), RoleData.getRoleData().getLoginResult().getSummoning_id());
        FormsManagement.HideForm(19);
        // 判断是否还有召唤兽
        if (UserMessUntil.getPetListTable().size() == 0) {// 没有
            TestPetJpanel.getLabname().setText("");
            TestPetJpanel.getLabHP().setText("");
            TestPetJpanel.getLabMP().setText("");
            TestPetJpanel.getLabAP().setText("");
            TestPetJpanel.getLabSP().setText("");
            TestPetJpanel.getLabEXP().setText("");
            TestPetJpanel.getLabpower().setText("");
            TestPetJpanel.getLabspeed().setText("");
            TestPetJpanel.getLabpointnumber().setText("");
            TestPetJpanel.getLabrootbone().setText("");
            TestPetJpanel.getLabintelligence().setText("");
            TestPetJpanel.getLablevel().setText("");
            TestPetJpanel.getLabloyalty().setText("");
            UserMessUntil.setChosePetMes(null);
        }
        // 判断是否有参战的召唤兽
        else if (RoleData.getRoleData().getLoginResult().getSummoning_id() != null) {
            exi2 = 0;

            for (int i = 0; i < UserMessUntil.getPetListTable().size(); ++i) {
                if (RoleData.getRoleData().getLoginResult().getSummoning_id().compareTo(UserMessUntil.getPetListTable().get(i).getSid()) == 0) {
                    exi2 = i;
                }
            }
            // 展示参战的召唤兽信息
            UserMessUntil.setChosePetMes(UserMessUntil.getPetListTable().get(exi2));
            PetAddPointMouslisten.showPetValue();
        } else {
            // 展示第一只召唤兽的信息
            UserMessUntil.setChosePetMes(UserMessUntil.getPetListTable().get(0));
            PetAddPointMouslisten.showPetValue();
        }

        // 关闭召唤兽技能面板
        FormsManagement.HideForm(18);
    }
}